package com.hopes.bizz.risk.hid.dto;

import com.hopes.bizz.risk.hid.entity.RiskHidCheckPlanEntity;
import com.hopes.boss.common.entity.BaseLogicEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import java.util.Date;
import java.util.List;

/**
 * @author daijie
 * @version 1.0
 * @date 2023/7/27 19:26
 * @Description:
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "隐患检查计划DTO")
public class RiskHidCheckPlanDTO extends BaseLogicEntity {

    private static final long serialVersionUID = 6991291040540980771L;

    public RiskHidCheckPlanEntity toPO() {
        RiskHidCheckPlanEntity entity = new RiskHidCheckPlanEntity();
        BeanUtils.copyProperties(this, entity);

        if (!this.hidCheckListConfigIdList.isEmpty()) {
            StringBuilder builder = new StringBuilder();
            for (Long id : this.hidCheckListConfigIdList) {
                builder.append(id).append(",");
            }
            builder.deleteCharAt(builder.length() - 1);
            entity.setHidCheckListConfigId(builder.toString());
        }

        if (!this.riskUnitIdList.isEmpty()) {
            StringBuilder builder = new StringBuilder();
            for (Long id : this.riskUnitIdList) {
                builder.append(id).append(",");
            }
            builder.deleteCharAt(builder.length() - 1);
            entity.setRiskUnitId(builder.toString());
        }

        if (!this.pushDateList.isEmpty()) {
            StringBuilder builder = new StringBuilder();
            for (String id : this.pushDateList) {
                builder.append(id).append(",");
            }
            builder.deleteCharAt(builder.length() - 1);
            entity.setPushDate(builder.toString());
        }

        if (!this.pushTimeList.isEmpty()) {
            StringBuilder builder = new StringBuilder();
            for (String id : this.pushTimeList) {
                builder.append(id).append(",");
            }
            builder.deleteCharAt(builder.length() - 1);
            entity.setPushTime(builder.toString());
        }
        return entity;
    }

    private Long id;

    private String planName;

    private String planNo;

    private List<Long> hidCheckListConfigIdList;

    private String checkObject;

    private Long recorder;

    private String recorderIdCard;

    private String checkPerson;

    private List<Long> riskUnitIdList;

    private Integer pushType;

    private String checkTime;

    private String pushCycle;

    private List<String> pushTimeList;

    private String pushMonth;

    private String pushWeek;

    private List<String> pushDateList;

    private Integer maxHandleHour;

    private Boolean runFlag;

    private Date preExecuteDate;

    private Date nextExecuteDate;

    private String remarks;

    private Long orgId;
}
